package flexUnitTests
{
	import de.slowpoke.flattr.Enum.FlattrButtonEnum;
	import de.slowpoke.flattr.Enum.FlattrButtonValue;
	import de.slowpoke.flattr.Enum.FlattrCategoryEnum;
	import de.slowpoke.flattr.Enum.FlattrCategoryValue;
	import de.slowpoke.flattr.Enum.FlattrLanguageEnum;
	import de.slowpoke.flattr.Enum.FlattrLanugageValue;
	import de.slowpoke.flattr.Error.FlattrError;
	import de.slowpoke.flattr.Flattr;
	import de.slowpoke.flattr.Thing;
	
	import flexunit.framework.Assert;
	
	import org.flexunit.asserts.assertNotNull;
	import org.flexunit.asserts.assertTrue;
	
	public class TestThing
	{
		
		public var thing:Thing;
		public var flattr:Flattr; 
		
		[Before]
		public function setUp():void
		{
			this.flattr = new Flattr(1234);
			this.thing = new Thing(this.flattr, "Title", "description", FlattrCategoryEnum.REST, FlattrLanguageEnum.GERMAN, "tag1,tag2,tag3", "http://example.org", FlattrButtonEnum.DEFAULT);
		}
		
		[After]
		public function tearDown():void
		{
		}
		
		[BeforeClass]
		public static function setUpBeforeClass():void
		{
		}
		
		[AfterClass]
		public static function tearDownAfterClass():void
		{
		}
		
		[Test]
		public function testSet_button():void
		{
			assertNotNull(this.thing);
			this.thing.button = new FlattrButtonValue("wrong");
		}
		
		[Test(expects="de.slowpoke.flattr.Error.FlattrError")]
		public function testSet_category():void
		{
			assertNotNull(this.thing);
			this.thing.category = new FlattrCategoryValue("does not exist");
		}
		
		[Test]
		public function testSet_description():void
		{
			assertNotNull(this.thing);
			this.thing.description = "";
		}
		
		[Test(expects="de.slowpoke.flattr.Error.FlattrError")]
		public function testSet_language():void
		{
			assertNotNull(this.thing);
			this.thing.language = new FlattrLanugageValue("Klingon");
		}
		
		[Test]
		public function testSubmit():void
		{
			assertTrue(this.thing.submit());
		}
		
		[Test(expects="de.slowpoke.flattr.Error.FlattrError")]
		public function testGetFlattrUrl():void
		{
			// TODO see Thing.getFlattrUrl()
			assertNotNull(this.thing.getFlattrUrl());
		}
		
		[Test]
		public function testSet_tags():void
		{
			assertNotNull(this.thing);
			this.thing.tags = "blaa,blaaa";
		}
		
		[Test]
		public function testThing():void
		{
			assertNotNull(this.thing);
		}
		
		[Test(expects="de.slowpoke.flattr.Error.FlattrError")]
		public function testSet_title():void
		{
			assertNotNull(this.thing);
			this.thing.title = "";
		}
		
		[Test]
		public function testSet_url():void
		{
			assertNotNull(this.thing);
			this.thing.url = "http://google.com";
		}
	}
}